<template>
  <div class="box">
    <div class="crumbs">
      <!--配置动态面包屑-->
      <el-breadcrumb separator="/" v-if="$route.path !== '/home'">
        <el-breadcrumb-item
          v-for="(item, index) in breadList"
          :key="item.index"
          :to="{ path: item.meta.path }"
        >
          {{ item.meta.title }}
        </el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="box__content">
      <div class="content">
        <h1 v-if="$route.path !== '/home'">
          <span>{{ caption }}</span>
        </h1>
        <slot></slot>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "box",
  props: ["caption"],
  data() {
    return {
      breadList: [],
    };
  },
  watch: {
    $route() {
      this.getBreadcrumb();
    },
  },
  created() {
    this.getBreadcrumb();
  },
  methods: {
    getBreadcrumb() {
      let matched = this.$route.matched;
      this.breadList = matched;
    },
  },
};
</script>

<style scoped lang="scss">
.box {
  max-height: 600px;
  padding-top: 10px;
  .crumbs {
    margin-left: 15px;
  }
  .box__content {
    box-shadow: 0 3px 20px rgba(0, 0, 0, 0.16);
    width: 96%;
    border-radius: 16px;
    margin: 10px 25px;
    background-color: #fff;
    .content {
      padding: 16px 20px;
      h1 {
        height: 30px;
        line-height: 30px;
        font-size: $largeFontSize;
        border-bottom: 3px solid $lineColor;
        color: $baseColor;

        span {
          color: #000;
          display: inline-block;
          height: 30px;
          line-height: 30px;
          border-bottom: 3px solid $baseColor;
        }
      }
    }
  }
}
</style>
